function res = solvess(x,rk,delta,sigma,psi1,psi2,omega1,eps1,omega2,eps2,omega3,eps3,s_ss,phi_inv,alpha_inv,kappa)


potest = x;

    qytest = omega1*potest^(-eps1);
    
    vytest = ( 1-omega1^(1/eps1)*qytest^((eps1-1)/eps1) ) / (1-omega1)^(1/eps1);
    
    vytest = vytest^(eps1/(eps1-1));
    
    aide = ((1-omega1)/vytest)^(-1/eps1);
    
    vktest = (rk*aide*(1-omega3)^(-1/eps3))^eps3;
    
    kntest = ( vktest^((eps3-1)/eps3) - (1-omega3)^(1/eps3) ) / omega3^(1/eps3);
    kntest = kntest^(eps3/(1-eps3));
    vntest = vktest*kntest;
    yntest = vntest/vytest;
    wtest = ((1-omega1)/vytest)^(1/eps1) * (vntest*omega3)^(1/eps3);
    ptest = (omega2*potest^(1-eps2)+1-omega2)^(1/(1-eps2));
    
    cntest = (yntest-delta*kntest)/( (1-omega2)*ptest^(eps2));
    
    aide = ptest*(cntest^(sigma))*psi1/wtest;
    ntest = aide^(-1/(sigma+psi2));
    
    ytest = yntest*ntest;
    qtest = qytest*ytest;
    ctest = cntest*ntest;
    cotest = omega2*ctest*(potest/ptest)^(-eps2);
    
 
    lhs = alpha_inv*s_ss+1;
    rhs = qtest+cotest+s_ss*(1+kappa+0.5*s_ss*phi_inv);
    
    
res = lhs - rhs;




    
